<?php
/*------------------------------------------
* @AUTHOR: TANDAT @EMAIL:tidusvn05@gmail.com
* @PHONE: +84933731173
* -----------------------------------------*/
class Website extends D_Cassandra_Abstract {
	
	/*
	 * NEW FUNCTION WITH CASSANDRA
	 * 
	 */
	public function all_website(){
		return $this->get_rows();
	}
	
	
	public function sampleData(){
		$websites = array("http://vnexpress.net" => array("name" => "Báo Điện Tử VnExpress"), 
						"http://zing.vn" => array("name" => "Báo Lá Cải của VNG")
				);
		$this->batch_insert($websites);
		
	}
	
	
	
	/*
	 * OLD FUNCTION WITH CASSANDRA
	*
	*/
	public function getByWebsiteId($website_id){
		$result = array();
			
		$keywords = $this->find($website_id)->current()->findManyToManyRowset('Keyword', 'WebsiteKeyword');
		if(count($keywords) > 0 ){
			foreach ($keywords as $kw){
				$result[$kw->id] = $kw->name;
			}
		}
		
		return $result;
	}
	
	public function listwebsite(){
		$sql=$this->select()->setIntegrityCheck(false)
			->from($this->_name)
            ->order('url');
		return $this->fetchAll($sql);
	}
	
	public function insert_website($data){
		return $this->insert($data);
	}
	public function deletewebsite($id){
		$where="id=$id";
		$this->delete($where);
	}
	
}

?>